The present invention relates to computer graphics, and more particularly to interactive graphics systems such as home video game platforms. Still more particularly this invention relates to Z-value clamping in the near-Z range when rendering anti-aliased scenes to maximize precision of visually important Z components and to avoid near-Z clipping.
Many of us have seen films containing remarkably realistic dinosaurs, aliens, animated toys and other fanciful creatures. Such animations are made possible by computer graphics. Using such techniques, a computer graphics artist can specify how each object should look and how it should change in appearance over time, and a computer then models the objects and displays them on a display such as your television or a computer screen. The computer takes care of performing the many tasks required to make sure that each part of the displayed image is colored and shaped just right based on the position and orientation of each object in a scene, the direction in which light seems to strike each object, the surface texture of each object, and other factors.
Because computer graphics generation is complex, computer-generated three-dimensional graphics just a few years ago were mostly limited to expensive specialized flight simulators, high-end graphics workstations and supercomputers. The public saw some of the images generated by these computer systems in movies and expensive television advertisements, but most of us couldn""t actually interact with the computers doing the graphics generation. All this has changed with the availability of relatively inexpensive 3D graphics platforms such as, for example, the Nintendo 64(copyright) and various 3D graphics cards now available for personal computers. It is now possible to interact with exciting 3D animations and simulations on relatively inexpensive computer graphics systems in your home or office.
Most 3D graphics computer systems render and prepare images for display in response to polygon vertex attribute data which typically includes a Z-axis (scene depth) value. A well known technique called Z-buffering is often used to properly render objects in accordance with their respective depth (i.e., distance from the viewer/camera) in a 3D scene. Since processing a lot of 3D image polygon vertex attribute data can become very time consuming, graphics system designers often employ a polygon culling and clipping process to eliminate the processing of the non-displayed image data. This non-displayed image data is typically polygon vertex data that is outside a viewing frustum bounded by predetermined xe2x80x9cclippingxe2x80x9d planes in a virtual 3D image rendering space called xe2x80x9ccamera spacexe2x80x9d (also called xe2x80x9cscreen spacexe2x80x9d). For example, portions of a 3D scene or object that are behind the camera (viewport) position need not be rendered and may be culled or clipped. Likewise, scene portions and 3D objects very far in the scene distance (i.e., far from the camera/eye position along the scene depth or Z-axis) need not be rendered.
Scene depth clipping may be performed using both a near clipping plane and a far clipping plane where the far clipping plane is many times the depth of the near clipping plane. Scene depth clipping may also be performed with a clipping plane at or behind the camera/eye position (i.e., the Z=0 plane) or without using a near clipping plane altogether. However, for various reasons not discussed in detail here, rendering 3D objects at or very close to the camera/eye position may cause certain data processing problems such as overflow and wrapping errors due to the small Z values involved. For example, in the case of geometry projection, vertices that get xe2x80x9ctoo closexe2x80x9d to the camera (Z=0) plane get a w (homogeneous coordinate scale factor) value that is very small. Dividing vertex x, y and z coordinates attributes by such small w values during screen-space transformation operations often causes precision and overflow problems-especially when w=0, where the resulting scale values are infinite. Clipping geometry to a near-plane avoids such problemsxe2x80x94each triangle with offending vertices is cut into pieces by the near-plane, and the half that is xe2x80x98too closexe2x80x99 is thrown away. Consequently, if scene depth clipping is performed using a near clipping plane in front of the camera/eye position, the near clipping plane should be positioned far enough in front of the camera that such overflow and wrapping errors do not occur.
Alternatively, if scene depth clipping is performed without using a near clipping plane, or with a clipping plane at or behind the camera/eye position, it may be necessary to burden the applications program with the responsibility of preventing such overflows and wrapping problems by policing the permissible distance between the camera position and a rendered object. A problem graphics system designers confronted in the past is how to avoid certain undesirable visual effects associated with the clipping of polygons of a displayed 3D image object that approaches the plane of the viewer (i.e., the camera/eye plane). In particular, graphics artists and game developers never want to see a 3D object clipped by a clipping plane placed in front of the viewer, as this produces a hole in the object and gives the appearance that objects are hollow. One solution is to define a six plane viewing frustrum clipping box having the near clipping plane very close to the eye/camera plane (i.e., the Z=0 plane) and establish an application program rule that no 3D animated objects should come closer to the eye/camera plane than the near clipping plane. With the near clipping plane placed very close to the eye/camera plane, it less likely that objects that need to be rendered somewhat near the eye/camera plane will come so close as to suffer the ill effects of clipping. Unfortunately, placing the near clipping plane very close to the eye/camera plane reduces the Z depth precision towards the far clipping plane. This Z precision problem is particularly exacerbated when only a limited number of Z-buffer bits are available for depth precision. The less bits that are available for representing a Z value, the greater the precision problem.
If performing Z-buffering in a graphics system where a large number a bits, for example, 24 bits or more, are available in the hardware for representing Z-axis depth values, Z value precision may not pose a problem. However, in certain systems or implementations where less bits are available for representing Z-axis depth values, lack of sufficient Z value precision can seriously effect Z-buffering performance and accuracy. For example, in certain implementations it may be desirable to perform data compression to accommodate storage memory constraints. If Z data compression is performed, the degree of Z precision for providing accurate Z-buffering may be adversely affected.
The present invention also solves the above problems by providing techniques and arrangements in a 3D graphics rendering system for preserving Z value depth precision when performing Z-buffering where the Z value depth data must be compressed.
The present invention also solves the above problems by providing techniques and arrangements in a 3D graphics rendering system for allowing a Z-clipping plane to be used very close to the eye/camera planexe2x80x94to avoid undesirable visual artifacts produced when objects are rendered too near to the eye/camera planexe2x80x94while preserving Z value depth precision.
The present invention also solves the above problems by providing techniques and arrangements in a 3D graphics rendering system for performing Z-buffering where the Z depth value associated with a polygon vertex is represented using, for example, 23 bits or less.
More specifically, in an exemplary embodiment of the present invention, a Z-clamping arrangement is employed to improve the precision of visually important Z components by providing Z value clamping within a predetermined range of the Z=0 eye/camera (viewport) plane. This arrangement allows a Z-clipping plane to be used very close to the eye/camera planexe2x80x94to avoid undesirable visual artifacts produced when objects rendered near to the eye/camera plane are clipped-while preserving Z precision. A near clipping plane, xe2x80x9cznearxe2x80x9d, is established at a Z plane very close to the Z=0 plane and a far clipping plane, xe2x80x9cz-farxe2x80x9d, is established at a Z plane far from the Z=0 plane. A clamping plane, xe2x80x9cznear2xe2x80x9d, is then established such that it is located at Z=znear * (1 less than  less than n), where n is an integer that effectively determines the Z resolution for the scene by setting the position of the znear2 plane relative to the znear plane. Z-buffering is performed for all pixels that lie within a range between the znear2 plane and the z-far clipping plane. Any pixels that lie within the range between the znear plane and znear2 plane have Z values clamped, for example, to zero or to the Z value of the clamping plane. Hardware geometry clipping is performed for all pixels where z less than znear.
In an example implementation, a conventional Z value compression circuit provided in the graphics pipeline is enhanced to perform Z-clamping within the predetermined range of Z values. The enhanced circuitry includes an adder for left-shifting the Z value one or more bits prior to compression and gates for masking out the most significant non-zero shifted bits to zero.